import { getDachshundRequest } from "@common/utils";
import sm4 from "@common/sm4";
import { CTX_PATH, SM4_KEY } from "@common/constants";
import Instance from "@common/remoteCallInterceptor";
import { UserUrls } from "../urls";

export default {
  modifyPwd: ({ oldPwd, newPwd }) => {
    let encOldPwd = sm4.encode({
      input: oldPwd,
      key: SM4_KEY,
    });
    let encNewPwd = sm4.encode({
      input: newPwd,
      key: SM4_KEY,
    });
    let req = getDachshundRequest(
      {
        oldPwd: encOldPwd,
        newPwd: encNewPwd,
      },
      [encOldPwd, encNewPwd]
    );
    return Instance.dachshundInstance.post(UserUrls.modifyPwd, req, {
      baseURL: CTX_PATH.getDachshundPrefix(),
    });
  },
};
